package com.yishe.biz.mysql;

import com.yishe.biz.BaseBiz;
import com.yishe.entites.mysql.YsStaff;
import com.yishe.entites.mysql.YsStaffCase;
import com.yishe.mapper.mysql.YsStaffCaseMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author : chusifeng
 * @version :1.0
 * @date :Create in 2021/4/11 18:35
 * @description: 员工课程信息
 * @package com.yishe.biz.mysql
 * @className YsStaffCaseBiz
 */
@Service
@Slf4j
public class YsStaffCaseBiz extends BaseBiz<YsStaffCaseMapper,YsStaffCase> {

    /**
     * 分配课程
     * @param param
     * @return
     */
    public String distributeToStaff(Map<String, String> param) {
        //查询是否存在记录
        String msg = "";
        YsStaffCase staffCase = new YsStaffCase();
        staffCase.setCaseNo(param.get("caseNo"));
        staffCase.setAccount(param.get("account"));
        YsStaffCase staffCaseOld = this.selectOne(staffCase);
        if (Objects.isNull(staffCaseOld)){
            this.insert(staffCase);
        } else {
            msg = "该员工已分配该课程";
        }
        return msg;
    }

}
